package com.danskin.wechat.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.danskin.wechat.dao.CustActivityVoteDao;
import com.danskin.wechat.entity.CustActivityVote;
import com.danskin.wechat.entity.example.CustActivityVoteExample;
import com.danskin.wechat.entity.example.CustActivityVoteExample.Criteria;
import com.danskin.wechat.service.CustActivityVoteService;
import com.danskin.wechat.util.Page;

@Service
public class CustActivityVoteServiceImpl implements CustActivityVoteService {

	@Autowired
	private CustActivityVoteDao custActivityVoteDao;
	
	@Override
	public List<Map<String, Object>> listPageActivityVoteStatic(Page page) {
		List<Map<String,Object>> list = custActivityVoteDao.listPageActivityVoteStatic(page);
		return list;
	}

	@Override
	public int deleteCustActivityVoteStatic(Integer id) {
		int i = custActivityVoteDao.deleteByPrimaryKey(id);
		return i;
	}
	//查询该粉丝openId 参加的活动
	@Override
	public List<CustActivityVote> getCustVoteListByOpenIdAndActivityId(String OpenId, Integer activityId) {
		CustActivityVoteExample example=new CustActivityVoteExample();
		Criteria criteria = example.createCriteria();
		criteria.andActivityIdEqualTo(activityId);
		criteria.andOpenIdEqualTo(OpenId);
		List<CustActivityVote> list = custActivityVoteDao.selectByExample(example);
		return list;
	}

	@Override
	public int saveCustActivityVoteOption(CustActivityVote vote) {
		int i = custActivityVoteDao.insertSelective(vote);
		return i;
	}

}
